#!/usr/bin/env python

import sys

sys.path.insert(0,'../expanding_windows')

from expanding_windows import *


def enc_non_overlapping_windows(wndws, generation_size, field_size): # Create encoding vector of list of window borders (start and ending borders (0, 'generation_size') should be omitted)
	windows = wndws
	if not windows[0] == 0: windows = [0] + windows
	if not windows[-1] == generation_size: windows.append(generation_size)
	pick_window = np.random.randint(len(windows))
	enc_window_start = windows[pick_window]

	enc_vector = np.array([[]])
	for index in range(len(windows)-1):
		win = windows[index]
		next = windows[index+1]
		a = None
		if win == enc_window_start: 
			a = np.random.randint(field_size, size=(1,next-win))
		else: 
			a = np.zeros((1,next-win))
		enc_vector = np.hstack((enc_vector,a))

	return enc_vector

if __name__ == '__main__':
	
	generation_sizes = [40, 80, 120]
	field_sizes = [2, 256]
	windows = [[0.3],[0.4],[0.5],[0.6],[0.7],[0.4,0.7],[0.2,0.6],[0.6,0.8]] ## [0.3] means a seperation into 2 chunks. 30% important data. [0.4, 0.7] means a seperation into 3 chunks. 40% vital data, 30% important data. Percentages are borders => non-overlapping-windows (rest-percentage is least important data)
	cycles = 1
	upper_limit = 3 # * g_size

	for field_size in field_sizes:
		for generation_size in generation_sizes:
			for win in windows:
				window = create_windows(win, generation_size)
				run_simulation(field_size, generation_size, window, cycles, upper_limit*generation_size, enc_non_overlapping_windows)
